package com.tjsinfo.tjsoa.common;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import sun.java2d.pipe.SpanShapeRenderer.Simple;
/**
 * 日期格式转换类
 * @author wangxiaowei
 *
 */
public class DateTimeFromConver {
	/**
	 * 
	 * @param zoushu
	 * @return
	 */
	
	public int jisuanriqi(Date date){
		
		//���ȶ���һ��calendar������ʹ��getInstance()����ʵ��  
        Calendar   aCalendar=Calendar.getInstance();  
        //����Ұ����ֱ�Ӳ���date����  
        aCalendar.setTime(date);  
        //�����������һ���е���һ��  
        int   x=aCalendar.get(Calendar.WEEK_OF_YEAR);  
        return x;
	}
	/**
	 * �ж������Ƿ���ָ����Χ
	 * @param  ����ʱ��
	 * @param  ��ʼʱ��
	 * @param  ���������
	 * @return
	 */
	public boolean riqifanwei(Date date,Date date2,Date date3)
	{
		
		boolean start = false;
		if (date3.before(TestRiQi.afterNDay(date,1)) && date3.after(date2)) {
			start = true;
		}
		else if( DateTimeFromConver.zhuanhuariqi(date).equals(DateTimeFromConver.zhuanhuariqi(date3)))
		{
			start = true;
		}
		else if( DateTimeFromConver.zhuanhuariqi(date2).equals(DateTimeFromConver.zhuanhuariqi(date3)))
		{
			start = true;
		}
		return start;
	}
	
	/**
	 * 日期格式转
	 */
	public static String zhuanhuariqi(Date date)
	{
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		return dateFormat.format(date);
	}
	/**
	 * 日期格式转
	 */
	public static Date datetostr(String str)
	{
		Date date = null;
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		try {
			date = dateFormat.parse(str);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return date; 
	}
	/**
	 * 日期时间格式转
	 */
	public static Date datetimetostr(String str)
	{
		Date date = null;
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		try {
			date = dateFormat.parse(str);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return date;
	}
	
	public static String zhuanhuariqi2(Date date)
	{
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日");
		return dateFormat.format(date);
	}
	/**
	 * 日期时间格式转
	 */
	public static String strdatetimeto(Date date)
	{
		String str = null;
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		
		str = dateFormat.format(date);
	
		return str;
	}
	
	
	public static int getHoures(Date date)
	{
		SimpleDateFormat dateFormat = new SimpleDateFormat("HH");
		
		return  Integer.parseInt(dateFormat.format(date)); 
	}
	
	public static int getMinues(Date date)
	{
		SimpleDateFormat dateFormat = new SimpleDateFormat("mm");
		
		return  Integer.parseInt(dateFormat.format(date)); 
	}
}
